<?php
class TLInfo extends Controller {
	var $msg = '';
	
	function TLInfo()
	{
		parent::Controller();
	}
	
	function index()
	{
		if ($this->session->userdata('logged_in') != TRUE)
	    {
	        redirect('login/index');
	    }
		 
	    $this->load->model('filemanagementmodel');
	    $data['header_tel'] = $this->filemanagementmodel->getByPostion('header_tel');
	    $data['footer_add1'] = $this->filemanagementmodel->getByPostion('footer_add1');
	    
		$this->load->view('header');
		$this->load->view('tl-info-list-form', $data);
		$this->load->view('footer');
	}
	
	function save()
	{
	 	if ($this->session->userdata('logged_in') != TRUE)
	    {
	        redirect('login/index');
	    }
	    
	    
	    $this->load->model('filemanagementmodel');
	    $data['position'] = 'header_tel';
	    $data['file_name'] = $this->input->post('txtTel1');
		$this->filemanagementmodel->update($data);
		
		$data['position'] = 'footer_add1';
	    $data['file_name'] = $this->input->post('txtAdd1');
		$this->filemanagementmodel->update($data);
		
		$this->msg = "บันทึกข้อมูลเรียบร้อย";
		$data['header_tel'] = $this->filemanagementmodel->getByPostion('header_tel');
	    $data['footer_add1'] = $this->filemanagementmodel->getByPostion('footer_add1');
	    
	    $data['header_tel'] = $this->filemanagementmodel->getByPostion('header_tel');
	    $data['footer_add1'] = $this->filemanagementmodel->getByPostion('footer_add1');
		 
		$this->load->view('header');
		$this->load->view('tl-info-list-form', $data);
		$this->load->view('footer', $this->msg);
	}
}